/*
* @@name:	target_defaultmap.1
* @@type:	C
* @@operation:	run
* @@expect:	success
* @@version:	omp_5.2
*/
#include <stdlib.h>
#include <stdio.h>
#define N 2

int main(){
  typedef struct S_struct { int s; int A[N]; } S_struct_t;
  
  int         s;       //scalar int variable (scalar)
  int         A[N];    //aggregate variable  (array)
  S_struct_t  S;       //aggregate variable  (structure)
  int         *ptr;    //scalar, pointer variable (pointer)

  int         s1, s2, s3;

// Initialize everything to zero;
   s=2; s1=s2=s3=0; 
   A[0]=0; A[1]=0;
   S.s=0; S.A[0]=0; S.A[1]=0;
    
// Target Region 1
                   // Uses defaultmap to set scalars, aggregates & 
                   // pointers to normal defaults.  
    #pragma omp target \
            defaultmap(firstprivate: scalar)   /* may also be default */ \
            defaultmap(tofrom:       aggregate)/* may also be default */ \
            defaultmap(default:      pointer)  /* must be default */
    {
        s       = 3;            //SCALAR firstprivate, value not returned
 
        A[0]    = 3;  A[1] = 3; //AGGREGATE array, default map tofrom
 
                                //AGGREGATE structure, default tofrom
        S.s     = 2;
        S.A[0]  = 2;  S.A[1] = 2;

        ptr = &A[0];            //POINTER is private
        ptr[0] = 2;   ptr[1] = 2;
    }
   if(s==2 && A[0]==2 && S.s==2 && S.A[0]==2) 
      printf(" PASSED 1 of 5\n");
  
    
